import axios from 'axios'
import { Toast } from 'vant'
axios.defaults.baseURL="/api"
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    //启动加载提示
    Toast({
        type: 'loading',
        message: '加载中...',
        //禁止穿透点击
        forbidClick: true,
        //自动关闭提示的时间, 如果为0,则不会自动关闭
        duration: 0
    });
    return config;
}, function (error) {
    // 对请求错误做些什么
    //关闭加载提示
    Toast.clear();
    return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么
    //关闭加载提示
    Toast.clear();
    return response;
}, function (error) {
    // 对响应错误做点什么
    //关闭加载提示
    Toast.clear();
    return Promise.reject(error);
});

//获取轮播banner图
export const getBanner = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/Banner"
    })
}
//获取推荐的漫画小说
export const getRecommendFiction = (pageNum, pageSize) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/HomeFeed",
        params: {
            pageNum,
            pageSize
        }
    })
}
//获取十个每日推荐喜欢漫画
export const getHomeRecommendFiction = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/HomeRecommend"
    })
}
//获取热门新递的漫画列表
export const getClassPageSixComics = (pageNum, pageSize) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetClassPageSixComics",
        params: {
            id: 1151,
            pageNum,
            pageSize,
            isAll: 0
        }
    })
}
//获取新番推荐的轮播图
export const getNewBanner = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetClassPageHomeBanner",
    })
}
//获取漫画小说不同类型数据
export const getNovelType = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/AllLabel",
    })
}
//获取漫画小说不同种类
export const getNovelCategory = (styleId, areaId, order, isFree, isFinish) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/ClassPage",
        params: {
            styleId,
            areaId,
            order,
            isFree,
            pageNum: 1,
            pageSize: 20,
            isFinish
        }
    })
 }

//获取男生和女生模块的漫画类型内容
export const getBoyGirlcomics = (tabId) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetClassPageLayout",
        params: {
            tabId
        }
    })
}
//获取男女频道二级分类筛选漫画
export const getBoyGirlcomicsType = (moduleId) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetHomeSecondaryComics",
        params: {
            moduleId,
            pageNum: 1,
            pageSize: 10
        }
    })
}
//获取潜力新作的对应漫画小说数据
export const getPotent = (id) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetClassPageComicsRank",
        params: {
            id
        }
    })
}
//获取排行榜的信息
export const getRank = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/ListRank",
    })
}
//获取不同类型的排行榜信息
export const getRankType = (id) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetRankInfo",
        params: {
            id,
            offset: 0,
            subId: 0
        }
    })
}
//获取关键字搜索建议
export const searchSug = (term) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/SearchSug",
        params: {
            term
        }
    })
}
//搜索关键字内容展示该关键字的类型漫画小说
export const searchComics = (keyWord) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/Search",
        params: {
            keyWord
        }
    })
}

//获取热门搜索关键字
export const getKeyword = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/SearchRecommend",
        params:{
            num:10
        }
    })
}
//获取漫画小说的详情内容
export const getcomicDetail = (comicId) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/ComicDetail",
        params: {
            comicId
        }
    })
}
//获取漫画投喂榜&月票榜前三
export const getcomicList = (comicId) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetEntranceForRank",
        params: {
            comicId
        }
    })
}
//获取漫画所在的排行榜
export const getcomicRanking = (comicIds) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetStyleRank",
        params: {
            comicIds
        }
    })
}
//获取对应漫画章节内容图片&索引
export const getcomicImg = (epId) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/GetImageIndex",
        params: {
            epId
        }
    })
}
//获取对应漫画章节内容图片Token
export const getcomicToken = (urls) => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/ImageToken",
        params: {
            urls
        }
    })
}
//获取书架默认漫画列表
export const getdefaultComic = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/Recommend",
    })
}
//获取用户中心配置
export const getUserInfo = () => {
    return axios({
        method: "GET",
        url: "https://apis.netstart.cn/bcomic/UCenterConf",
    })
}